var server = require('../../../utils/server');
var cPage = 0;
var ctype = "0";
Page({

	tabClick:function(e){
        var index = e.currentTarget.dataset.index
		var classs= ["text-normal","text-normal","text-normal","text-normal","text-normal","text-normal"]
		classs[index] = "text-select"
		this.setData({tabClasss:classs,tab:index})

		var types= [1,2,3]

		cPage = 0;
		ctype = types[index];
		this.data.coupons = [];
		this.getEvaluateLists(ctype,cPage);
    this.setData({types:ctype});
	},
  goseller:function(e){
    let seller_id = e.currentTarget.dataset.index
    // console.log(seller_id)
    if (this.data.types==1){
        wx:wx.navigateTo({
          url: '../../storedtl/storedtl?objectId=' + seller_id
        })
    }
  },
	
	// onReachBottom: function () {
	// 	// this.getEvaluateLists(ctype,++cPage);
	// 	wx.showToast({
	// 	  title: '加载中',
	// 	  icon: 'loading'
	// 	})
	// },
	onPullDownRefresh: function () {
    
	cPage = 0;
	this.data.orders = [];
        this.getEvaluateLists(ctype,cPage);
	},


	data: {
    types:1,
		coupons: [],
        tabClasss:["text-select","text-normal","text-normal","text-normal","text-normal"],

	},
    onLoad:function(option){
    this.getEvaluateLists(1);
	},
    getEvaluateLists:function(cType){
        let that = this;
        let _params={
          username: getApp().globalData.username,
          token:getApp().globalData.token,
          state: cType
        }
    //   server.postJSON('/sellercoupons/my-coupons',_params,function(res){
    //     // console.log(res)
    //     let coupons = res.data.list

    //         that.setData({
    //           coupons: coupons
    //             });
	// 	});
        server.send('/sellercoupons/my-coupons', 'POST', _params).then(res => {
            // console.log(res)
            let coupons = res.list

            that.setData({
                coupons: coupons
            });
        });
	    

	},
});